package net.huashitong.synthetical.TaskJob.Service;

import com.sirdc.modules.core.dao.BaseDao;
import com.sirdc.modules.sys.base.StringPKService;
import com.sirdc.modules.sys.service.SysTableService;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.synthetical.TaskJob.Entity.TaskSituation;
import net.huashitong.synthetical.TaskJob.dao.TaskJobDao;
import net.huashitong.synthetical.TaskJob.dao.TaskSituationDao;
import net.huashitong.synthetical.TaskJob.filter.TaskSituationFilter;
import net.huashitong.synthetical.question.entity.SupervisionLog;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.logging.Filter;

/**
 * 落实情况
 */
@Service
public class TaskSituationService  extends StringPKService<TaskSituation> {
    @Autowired
    SysTableService tableService;
    @Autowired
    private TaskJobDao taskJobDao;
    @Autowired
    private TaskSituationDao taskSituationDao;
    @Override
    protected BaseDao<TaskSituation, String> getDao() {
        return taskSituationDao;
    }

    /**
     * 查询落实情况
     *
     * @param taskId
     * @return
     */
    public List<TaskSituation> getTaskId(String taskId) {
        return taskSituationDao.getTaskId(taskId);
    }

    public List<TaskSituation> getTaskSituationList(TaskSituationFilter filter) {
        return taskSituationDao.getTaskSituationList(filter);
    }

    /**
     * 保存落实情况
     *
     * @param filter
     */
    public void saveTaskSituation(TaskSituationFilter filter) {
        if (StringUtils.isBlank(filter.getTaskId())){
            System.out.println("无添加记录");
        }else {
            TaskSituation taskSituation = new TaskSituation();
            BeanUtils.copyProperties(filter,taskSituation);
            save(taskSituation);
        }
    }

    @Override
    protected void beforeSave(TaskSituation obj) {
        obj.setSysId(tableService.updateMaxSysId("t_task_situation",null));
    }
}
